﻿@model TopicModel
@using Nop.Web.Models.Topics;
@if (Model.IsPasswordProtected)
{
    <script type="text/javascript">    
        $(document).ready(function () {
            $('#ph-topic-@Model.Id').hide();            
            $('#ph-password-@Model.Id #password-@Model.Id').select().focus();
        });    
        function OnAuthenticateSuccess@(Model.Id)(context) {
            if (context.Authenticated)
            {
                $('#ph-title-@Model.Id .topic-html-content-title h2.topic-html-content-header').html(context.Title);
                if ($('#ph-title-@Model.Id .topic-html-content-title h2.topic-html-content-header').text().length == 0)
                {
                    $('#ph-title-@Model.Id').hide();
                }
                $('#ph-topic-@Model.Id .topic-html-content-body').html(context.Body);
                $('#ph-password-@Model.Id').hide();
                $('#ph-topic-@Model.Id').show();
            }
            else
            {
                $('#password-error-@Model.Id').text(context.Error);
                $('#ph-password-@Model.Id #password-@Model.Id').select().focus();
            }
        }
    </script>

    <div class="topic-password" id="ph-password-@Model.Id">
        @using (Ajax.BeginRouteForm("TopicAuthenticate", new AjaxOptions
                                                             {
                                                                 HttpMethod = "Post",
                                                                 OnSuccess = "OnAuthenticateSuccess" + @Model.Id,
                                                                 LoadingElementId = "authenticate-progress-" + @Model.Id
                                                             }))
        {
            @Html.HiddenFor(model => model.Id)
            <div class="enter-password-title">
                @T("Topic.EnterPassword")
            </div>
            <div class="enter-password-form">
                @Html.Password("password", null, new { id = "password-" + @Model.Id })
                <input type="submit" value="@T("Topic.Button")" class="button-1 topic-password-button" />
                <span id="authenticate-progress-@Model.Id" style="display: none;" class="please-wait">@T("Common.Wait...")</span>
            </div>
            <div class="password-error">
                <span id="password-error-@Model.Id"></span>
            </div>
        }
    </div>

  @*  <div class="panel panel-default form-panel" id="ph-topic-@Model.Id">
        <div id="ph-title-@Model.Id">
            <div class="panel-heading">
                <h3>@Model.Title</h3>
            </div>
        </div>
        <div class="panel-body">
            @Html.Raw(Model.Body)
        </div>
    </div>*@


    <div class="features_items " id="ph-topic-@Model.Id"><!--features_items-->
        <h2 class="title text-center " id="ph-title-@Model.Id">@Model.Title</h2>
        <div class="custom-page-box-div">
            @Html.Raw(Model.Body)
        </div>
						
    </div>



}
else
{

        if (!String.IsNullOrEmpty(Model.Title))
        {
            <div class="features_items"><!--features_items-->
                <h2 class="title text-center">@Model.Title</h2>
                <div class="custom-page-box-div">
                    @Html.Raw(Model.Body)
                </div>
						
            </div>



            


        }else
        {
            <div class="custom-page-box-div">
                @Html.Raw(Model.Body)
            </div>

        }





}

<br/>